//查询指定url参数
 function GetQueryString(name) {
     var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
     var r = window.location.search.substr(1).match(reg);
     if(r!=null)return  unescape(r[2]); return null;
}

  var id = GetQueryString("id");
  var obj;
  $.ajax({
            url : "/app/store/detail.api",
            type : "post",
            data:{
              "id":id
            },
            success : function(datas){
              console.log(datas);
            var html ="";
            obj = datas.data;
            var imgs = obj.imgs;
            if(imgs!=null){
              imgs=imgs.split(",");
              for(i=0;i<imgs.length;i++){
                var img = imgs[i];
                html = html + 
                 '<div class="swiper-slide" onclick="javascript:void(return 0;);">'+
                '  <img class="img" src="'+img+'">'+
                '</div>'
              }
              $(".swiper-wrapper").html(html);
              var swiper = new Swiper('.swiper-container', {
                pagination: '.swiper-pagination',
                paginationClickable: true,
                parallax: true,
                speed: 1000,
                autoplay: 1000,
              });
            }
            
            $(".productName").text(obj.goodsName);
            $(".storeDeliverFee").text(obj.dispatchingFee);
            $(".sellNum").text(obj.sellNum);
            $(".productSell").text(obj.salePrice);
            $("#shopFee").text(obj.salePrice);
            $("#shopDispatherFee").text(obj.dispatchingFee);
            $(".content").html(obj.detailDescription);

            }
        });

   //购买点击事件
  $(".btnGoodsBuy").click(function(){
       if (/(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)) {  
          //判断iPhone|iPad|iPod|iOS
         var message = {"method":"buy","args":'{"goodsId":"'+id+'"}'};
         window.webkit.messageHandlers.webViewApp.postMessage(message);
      } else if (/(Android)/i.test(navigator.userAgent)) {   //判断Android
         window.location.href='http://xshop/doAction?param={"goodsId":"'+id+'"}'
      }
  });
  $(".goodsEvaluateSpan").click(function(){
      $(".content").html(obj.detailDescription);
  });
  $(".goodsAttributeSpan").click(function(){
      $(".content").html(obj.attribute);
  });